﻿using Dapper;

namespace Iot.HistoryVault;

public static class SqlIetHistoryHelp
{
    public static bool TableExists(this ISqlIetHistoryVault historyVault, string tableName)
    {
        const string sql = "SELECT count(*) FROM sqlite_master WHERE type = 'table' AND name = @TableName";
        using var db = historyVault.GetConnection();
        return db.ExecuteScalar<int>(sql, new { TableName = tableName }) > 0;
    }
}